home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / views / BottomNav.as next >
Encoding:
Text File  |  2008-05-21  |  13.9 KB  |  430 lines

  1. package views
  2. {
  3.    import events.NavigationEvent;
  4.    import flash.events.Event;
  5.    import flash.events.MouseEvent;
  6.    import flash.utils.getDefinitionByName;
  7.    import model.PresentationModel;
  8.    import mx.binding.Binding;
  9.    import mx.binding.IWatcherSetupUtil;
  10.    import mx.collections.ArrayCollection;
  11.    import mx.containers.Canvas;
  12.    import mx.controls.Alert;
  13.    import mx.controls.Button;
  14.    import mx.controls.Label;
  15.    import mx.core.UIComponentDescriptor;
  16.    import mx.core.mx_internal;
  17.    import mx.events.PropertyChangeEvent;
  18.    import views.Groups.PageNavigation;
  19.    
  20.    public class BottomNav extends Canvas
  21.    {
  22.       private static var _watcherSetupUtil:IWatcherSetupUtil;
  23.       
  24.       private var _bindings:Array;
  25.       
  26.       public var _bindingsByDestination:Object;
  27.       
  28.       [Bindable]
  29.       private var _867085359_PageNavigation1:PageNavigation;
  30.       
  31.       [Bindable]
  32.       private var _1166362513printBtn:Button;
  33.       
  34.       public var _bindingsBeginWithWord:Object;
  35.       
  36.       [Bindable]
  37.       private var _1732660444spreadsBtn:Button;
  38.       
  39.       [Bindable]
  40.       private var _1857328081presentationModel:PresentationModel;
  41.       
  42.       [Bindable]
  43.       private var _681920764_Label1:Label;
  44.       
  45.       [Bindable]
  46.       private var _1080376550readBtn:Button;
  47.       
  48.       private var _watchers:Array;
  49.       
  50.       [Bindable]
  51.       private var _1880932050searchResults:ArrayCollection;
  52.       
  53.       [Bindable]
  54.       private var _975152270browseBtn:Button;
  55.       
  56.       private var _documentDescriptor_:UIComponentDescriptor;
  57.       
  58.       public function BottomNav()
  59.       {
  60.          _documentDescriptor_ = new UIComponentDescriptor({
  61.             "type":Canvas,
  62.             "propertiesFactory":function():Object
  63.             {
  64.                return {
  65.                   "width":1280,
  66.                   "height":45,
  67.                   "childDescriptors":[new UIComponentDescriptor({
  68.                      "type":Button,
  69.                      "id":"spreadsBtn",
  70.                      "events":{"click":"__spreadsBtn_click"},
  71.                      "propertiesFactory":function():Object
  72.                      {
  73.                         return {
  74.                            "buttonMode":true,
  75.                            "styleName":"bottomNavBtn",
  76.                            "label":"Spreads",
  77.                            "x":56,
  78.                            "y":0,
  79.                            "width":98,
  80.                            "height":36
  81.                         };
  82.                      }
  83.                   }),new UIComponentDescriptor({
  84.                      "type":Label,
  85.                      "id":"_Label1",
  86.                      "propertiesFactory":function():Object
  87.                      {
  88.                         return {
  89.                            "styleName":"txt",
  90.                            "x":225,
  91.                            "y":9
  92.                         };
  93.                      }
  94.                   }),new UIComponentDescriptor({
  95.                      "type":PageNavigation,
  96.                      "id":"_PageNavigation1",
  97.                      "propertiesFactory":function():Object
  98.                      {
  99.                         return {
  100.                            "x":507,
  101.                            "y":0,
  102.                            "styleName":"pageNav"
  103.                         };
  104.                      }
  105.                   }),new UIComponentDescriptor({
  106.                      "type":Button,
  107.                      "id":"readBtn",
  108.                      "events":{"click":"__readBtn_click"},
  109.                      "propertiesFactory":function():Object
  110.                      {
  111.                         return {
  112.                            "buttonMode":true,
  113.                            "label":"Read",
  114.                            "styleName":"readBtn",
  115.                            "width":98,
  116.                            "height":36,
  117.                            "x":854,
  118.                            "y":0
  119.                         };
  120.                      }
  121.                   }),new UIComponentDescriptor({
  122.                      "type":Button,
  123.                      "id":"browseBtn",
  124.                      "events":{"click":"__browseBtn_click"},
  125.                      "propertiesFactory":function():Object
  126.                      {
  127.                         return {
  128.                            "buttonMode":true,
  129.                            "visible":false,
  130.                            "label":"Browse",
  131.                            "styleName":"browseBtn",
  132.                            "width":111,
  133.                            "height":36,
  134.                            "x":854,
  135.                            "y":0
  136.                         };
  137.                      }
  138.                   }),new UIComponentDescriptor({
  139.                      "type":Button,
  140.                      "id":"printBtn",
  141.                      "events":{"click":"__printBtn_click"},
  142.                      "propertiesFactory":function():Object
  143.                      {
  144.                         return {
  145.                            "buttonMode":true,
  146.                            "label":"Print",
  147.                            "styleName":"printBtn",
  148.                            "width":94,
  149.                            "height":36,
  150.                            "x":1122,
  151.                            "y":0
  152.                         };
  153.                      }
  154.                   })]
  155.                };
  156.             }
  157.          });
  158.          super();
  159.          mx_internal::_document = this;
  160.          this.styleName = "bottomNav";
  161.          this.width = 1280;
  162.          this.height = 45;
  163.       }
  164.       
  165.       public static function set watcherSetupUtil(param1:IWatcherSetupUtil) : void
  166.       {
  167.          BottomNav._watcherSetupUtil = param1;
  168.       }
  169.       
  170.       private function message(param1:String) : void
  171.       {
  172.          Alert.show(param1,"Hint");
  173.       }
  174.       
  175.       private function _BottomNav_bindingsSetup() : void
  176.       {
  177.          var binding:Binding = null;
  178.          if(!_bindings)
  179.          {
  180.             _bindings = [];
  181.          }
  182.          if(!_watchers)
  183.          {
  184.             _watchers = [];
  185.          }
  186.          binding = new Binding(this,function():String
  187.          {
  188.             var _loc1_:* = undefined;
  189.             var _loc2_:* = undefined;
  190.             _loc1_ = formatIssueString(presentationModel.currentIssue);
  191.             return _loc1_ == undefined ? null : String(_loc1_);
  192.          },function(param1:String):void
  193.          {
  194.             _Label1.text = param1;
  195.          },"_Label1.text");
  196.          _bindings[0] = binding;
  197.          binding = new Binding(this,function():PresentationModel
  198.          {
  199.             return presentationModel;
  200.          },function(param1:PresentationModel):void
  201.          {
  202.             _PageNavigation1.presentationModel = param1;
  203.          },"_PageNavigation1.presentationModel");
  204.          _bindings[1] = binding;
  205.       }
  206.       
  207.       public function __spreadsBtn_click(param1:MouseEvent) : void
  208.       {
  209.          clickHandler(param1);
  210.       }
  211.       
  212.       [Bindable(event="propertyChange")]
  213.       public function get printBtn() : Button
  214.       {
  215.          return this._1166362513printBtn;
  216.       }
  217.       
  218.       public function set _PageNavigation1(param1:PageNavigation) : void
  219.       {
  220.          var _loc2_:Object = null;
  221.          _loc2_ = this._867085359_PageNavigation1;
  222.          if(_loc2_ !== param1)
  223.          {
  224.             this._867085359_PageNavigation1 = param1;
  225.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_PageNavigation1",_loc2_,param1));
  226.          }
  227.       }
  228.       
  229.       public function set presentationModel(param1:PresentationModel) : void
  230.       {
  231.          var _loc2_:Object = null;
  232.          _loc2_ = this._1857328081presentationModel;
  233.          if(_loc2_ !== param1)
  234.          {
  235.             this._1857328081presentationModel = param1;
  236.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"presentationModel",_loc2_,param1));
  237.          }
  238.       }
  239.       
  240.       [Bindable(event="propertyChange")]
  241.       public function get _PageNavigation1() : PageNavigation
  242.       {
  243.          return this._867085359_PageNavigation1;
  244.       }
  245.       
  246.       [Bindable(event="propertyChange")]
  247.       public function get presentationModel() : PresentationModel
  248.       {
  249.          return this._1857328081presentationModel;
  250.       }
  251.       
  252.       private function clickHandler(param1:Event) : void
  253.       {
  254.          if(-1 == presentationModel.numPages)
  255.          {
  256.             trace("-1 == numPages");
  257.             message("Use \'Browse By Cover\' to choose a magazine.");
  258.             return;
  259.          }
  260.          switch(param1.target)
  261.          {
  262.             case spreadsBtn:
  263.                dispatchEvent(new NavigationEvent(NavigationEvent.SPREADS_TAB,null,true));
  264.                break;
  265.             case readBtn:
  266.                dispatchEvent(new NavigationEvent(NavigationEvent.READ_MODE,null,true));
  267.                readBtn.visible = false;
  268.                browseBtn.visible = true;
  269.                break;
  270.             case browseBtn:
  271.                dispatchEvent(new NavigationEvent(NavigationEvent.SPREAD_MODE,null,true));
  272.                readBtn.visible = true;
  273.                browseBtn.visible = false;
  274.                break;
  275.             case printBtn:
  276.                dispatchEvent(new NavigationEvent(NavigationEvent.PRINT,null,true));
  277.          }
  278.          trace("clickHandler in BottomNav for " + param1.target);
  279.       }
  280.       
  281.       [Bindable(event="propertyChange")]
  282.       public function get spreadsBtn() : Button
  283.       {
  284.          return this._1732660444spreadsBtn;
  285.       }
  286.       
  287.       public function set printBtn(param1:Button) : void
  288.       {
  289.          var _loc2_:Object = null;
  290.          _loc2_ = this._1166362513printBtn;
  291.          if(_loc2_ !== param1)
  292.          {
  293.             this._1166362513printBtn = param1;
  294.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"printBtn",_loc2_,param1));
  295.          }
  296.       }
  297.       
  298.       public function __readBtn_click(param1:MouseEvent) : void
  299.       {
  300.          clickHandler(param1);
  301.       }
  302.       
  303.       [Bindable(event="propertyChange")]
  304.       public function get _Label1() : Label
  305.       {
  306.          return this._681920764_Label1;
  307.       }
  308.       
  309.       [Bindable(event="propertyChange")]
  310.       public function get readBtn() : Button
  311.       {
  312.          return this._1080376550readBtn;
  313.       }
  314.       
  315.       [Bindable(event="propertyChange")]
  316.       public function get searchResults() : ArrayCollection
  317.       {
  318.          return this._1880932050searchResults;
  319.       }
  320.       
  321.       public function __printBtn_click(param1:MouseEvent) : void
  322.       {
  323.          clickHandler(param1);
  324.       }
  325.       
  326.       public function set spreadsBtn(param1:Button) : void
  327.       {
  328.          var _loc2_:Object = null;
  329.          _loc2_ = this._1732660444spreadsBtn;
  330.          if(_loc2_ !== param1)
  331.          {
  332.             this._1732660444spreadsBtn = param1;
  333.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"spreadsBtn",_loc2_,param1));
  334.          }
  335.       }
  336.       
  337.       public function set readBtn(param1:Button) : void
  338.       {
  339.          var _loc2_:Object = null;
  340.          _loc2_ = this._1080376550readBtn;
  341.          if(_loc2_ !== param1)
  342.          {
  343.             this._1080376550readBtn = param1;
  344.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"readBtn",_loc2_,param1));
  345.          }
  346.       }
  347.       
  348.       private function formatIssueString(param1:int) : String
  349.       {
  350.          trace("format issue string");
  351.          if(null == presentationModel.monthString || null == presentationModel.yearString)
  352.          {
  353.             return "";
  354.          }
  355.          return presentationModel.monthString + " " + presentationModel.yearString;
  356.       }
  357.       
  358.       public function set _Label1(param1:Label) : void
  359.       {
  360.          var _loc2_:Object = null;
  361.          _loc2_ = this._681920764_Label1;
  362.          if(_loc2_ !== param1)
  363.          {
  364.             this._681920764_Label1 = param1;
  365.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_Label1",_loc2_,param1));
  366.          }
  367.       }
  368.       
  369.       public function set searchResults(param1:ArrayCollection) : void
  370.       {
  371.          var _loc2_:Object = null;
  372.          _loc2_ = this._1880932050searchResults;
  373.          if(_loc2_ !== param1)
  374.          {
  375.             this._1880932050searchResults = param1;
  376.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchResults",_loc2_,param1));
  377.          }
  378.       }
  379.       
  380.       private function _BottomNav_bindingExprs() : void
  381.       {
  382.          var _loc1_:* = undefined;
  383.          _loc1_ = formatIssueString(presentationModel.currentIssue);
  384.          _loc1_ = presentationModel;
  385.       }
  386.       
  387.       public function __browseBtn_click(param1:MouseEvent) : void
  388.       {
  389.          clickHandler(param1);
  390.       }
  391.       
  392.       public function set browseBtn(param1:Button) : void
  393.       {
  394.          var _loc2_:Object = null;
  395.          _loc2_ = this._975152270browseBtn;
  396.          if(_loc2_ !== param1)
  397.          {
  398.             this._975152270browseBtn = param1;
  399.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"browseBtn",_loc2_,param1));
  400.          }
  401.       }
  402.       
  403.       [Bindable(event="propertyChange")]
  404.       public function get browseBtn() : Button
  405.       {
  406.          return this._975152270browseBtn;
  407.       }
  408.       
  409.       override public function initialize() : void
  410.       {
  411.          var target:BottomNav = null;
  412.          var watcherSetupUtilClass:Object = null;
  413.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  414.          _BottomNav_bindingsSetup();
  415.          target = this;
  416.          if(_watcherSetupUtil == null)
  417.          {
  418.             watcherSetupUtilClass = getDefinitionByName("_views_BottomNavWatcherSetupUtil");
  419.             watcherSetupUtilClass["init"](null);
  420.          }
  421.          _watcherSetupUtil.setup(this,function(param1:String):*
  422.          {
  423.             return target[param1];
  424.          },_bindings,_watchers);
  425.          super.initialize();
  426.       }
  427.    }
  428. }
  429.  
  430.